#2.5

import jieba
import wordcloud

def useWordClound(txtname):
    f = open(txtname,"r",encoding="utf-8")
    t = f.read()
    f.close()
    ls = jieba.lcut(t)
    txt = " ".join(ls)
    w = wordcloud.WordCloud( font_path="msyh.ttc",\
                            width = 1000,height = 700,\
                            background_color = "white")
    w.generate(txt)
    w.to_file("Lab2\wordcloud.png")

useWordClound("Lab2\天龙八部.txt")